<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const p1 = new Promise((resolve, reject) => {
            console.log('开始请求数据');
            try {
                // throw new Error('数据请求网络错误!!!')
                setTimeout(() => {
                    console.log('数据请求成功');
                    resolve('ok')

                }, 2000)
            } catch (e) {
               //catch接收的e就是错误对象
                console.log(e);
                //e上有一个message属性,就是当前错误的信息
                console.log(e.message);
                reject(e.message)
            }



        })
        console.log('p1', p1);
    </script>
</body>

</html>